package fdq.service;

import fdq.mapper.MessageMapper;
import fdq.mapper.UserMapper;
import fdq.pojo.Message;
import fdq.utils.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

public class MessageService {
    SqlSession sqlSession = MybatisUtil.getSqlSession();
    MessageMapper messageMapper = sqlSession.getMapper(MessageMapper.class);

    public Message[] selectAllMessages(){
        Message[] allMessages = messageMapper.selectAllMessages();
        return allMessages;
    }

    public int insertMessage(String mname, String message){
        Message newMessage = new Message(mname,message);
        int inserted = messageMapper.insertMessage(newMessage);
        return inserted;
    }

    public int deleteMessage(int mid){
        int deleted = messageMapper.deleteMessage(mid);
        return deleted;
    }
}
